/**
 * Created by Administrator on 2017/7/6.
 */
define(function(require, exports){
	var pubjs = require('pubjs');
	var $ = require('jquery');
	var grid  = require('@base/highGrid');
	var util = require('util');
	var ChannelGrid = grid.base.extend({
		init: function(config){
			config = pubjs.conf(config, {
					url: 'channel/list',
					param: {
						'order': 'impressions|-1,clicks|-1'
					},
					cols: [
						// {type:"id"}
						{name:"channel_id",text:LANG("渠道Id"),align:'center',width:80}
						,{name:"ChannelName",text:LANG("渠道"),width:200,render:'renderName',align:'left'}
					],
					subs: ['sweety', 'period', 'mediaAndAd', 'geo', 'client', 'campaign', 'product'],
					hasSwitch: false,
					hasSubGrid: false,
					auto_load: false,
					reqType: 'websocket',
					gridName: 'channelSet',
					exportParam: 'channel/list',
					tab: pubjs.config('metricsGroup/overviewSpot/tabs'),
					// default_metrics : pubjs.config('metricsGroup/overviewSpot/metrics'),
					subField: 'spot',
					subFilter: 'subFilter'
				}
			);
			this.Super('init', arguments);
		},
		renderName: function(i, val){
			var name = LANG(val) || '-';
			return $('<div class="text-truncate"/>').text(name).attr('title', name);
		}
	})
	exports.channelGrid = ChannelGrid;
	var AdsenseGrid = grid.base.extend({
		init: function(config){
			config = pubjs.conf(config, {
					url: 'spot/list',
					param: {
						'order': 'impressions|-1,clicks|-1'
					},
					cols: [
						// {type:"id"}
						{name:"_id",text:LANG("广告位Id"),align:'center',width:80}
						,{name:"Name",text:LANG("广告位"),width:200,render:'renderName',align:'left'}
					],
					subs: ['sweety', 'period', 'mediaAndAd', 'geo', 'client', 'campaign', 'product'],
					tab: pubjs.config('metricsGroup/overviewSpot/tabs'),
					hasSwitch: false,
					hasSubGrid: false,
					auto_load: false,
					reqType: 'websocket',
					gridName: 'channelSet',
					exportParam: 'spot/list'
				}
			);
			this.Super('init', arguments);
		},
		renderName: function(i, val){
			var name = LANG(val) || '-';
			return $('<div class="text-truncate"/>').text(name).attr('title', name);
		}
	})
	exports.adsenseGrid = AdsenseGrid;
	var OrderGrid = grid.base.extend({
		init: function(config){
			config = pubjs.conf(config, {
					url: 'overview/deal',
					param: {
						'order': 'impressions|-1,clicks|-1'
					},
					cols: [
						// {type:"id"}
						{name:"_id",text:LANG("订单Id"),align:'center',width:80}
						,{name:"Name",text:LANG("订单"),width:200,render:'renderName',align:'left'}
					],
					subs: ['sweety', 'period', 'mediaAndAd', 'geo', 'client', 'campaign', 'product'],
					tab: pubjs.config('metricsGroup/overviewSpot/tabs'),
					hasSwitch: false,
					hasSubGrid: false,
					auto_load: false,
					reqType: 'websocket',
					gridName: 'adsenseSet',
					exportParam: 'overview/deal'
				}
			);
			this.Super('init', arguments);
		},
		renderName: function(i, val){
			var name = LANG(val) || '-';
			return $('<div class="text-truncate"/>').text(name).attr('title', name);
		}
	})
	exports.orderGrid = OrderGrid;
});